/*
 * CurrentOptions.h
 *
 *  Created on: 17 июн. 2022 г.
 *      Author: nikita
 */

#ifndef SRC_MATH_STUFF_CURRENTOPTIONS_H_
#define SRC_MATH_STUFF_CURRENTOPTIONS_H_

#include "../STL_includes.h"
#include "../Typedefs.h"
#include "MVariable.h"
#include "MConstant.h"
#include "../Static_classes/SemanticAnalyzer/SemanticAnalyzer.h"

namespace STC_calc
{
/*
* The CurrentOptions class defines the
* program's behavior: working mode, flags
* variables etc.
*
* This class includes a pointer to out value.
* Also it contains a function needed to be
* counted if the working mode supposes that.
*/
class CurrentOptions
{
public:
	enum Modes
	{
        mode_undef,
		mode_simple_count,
		mode_standart_function,
		mode_exec_file,
		mode_graphic,
		mode_graph_diff,
		mode_graph_integr,
		mode_IF1,
		mode_IF0
	};
private:
    std::pair<Modes, bool> current_mode;
    std::pair<std::string, bool> string_for_execution;
	std::set<std::string> flags;

	std::map<std::string, std::shared_ptr<MVariable>> var_params;
    std::map<std::string, std::shared_ptr<MConstant>> const_params;
public:

    CurrentOptions(const Modes mode = mode_standart_function, const std::string& execution_str = "", const string_vector& flags_up = {});
	~CurrentOptions();
	CurrentOptions(const CurrentOptions& A);

	bool get_flag(const std::string& flag_name);
	Modes get_mode(){return current_mode;}
	std::string get_exe_string(){return string_for_execution;}

    void set_exe_string(const std::string& func);
    void set_mode(const Modes mode);
    bool is_func_empty();

    void add_variable(const string_list& args);
	void add_variable(const std::shared_ptr<MVariable> var);
	void add_variable(const std::string& name, const long double min, const long double max, const long double steps = 1000);

    void add_constant(const string_list& args);
    void add_constant(const std::shared_ptr<MVariable> var);
    void add_constant(const std::string& name, const long double value);

    std::pair<std::shared_ptr<MVariable>, bool> get_variable(const std::string& name);
    bool is_var(const std::string& str);
    std::pair<std::shared_ptr<MConstant>, bool> get_constant(const std::string& name);
    bool is_const(const std::string& str);

	void set_flag(const std::string& flag_name);
};

} /* namespace STC_calc */

#endif /* SRC_MATH_STUFF_CURRENTOPTIONS_H_ */
